#include <iostream> 
#include <string>
#include <map>
#include <queue>
using namespace std;

int main(){
	string s = "eeeeee";
//	cin >> s;
	map<double,int> mp;
	queue<double> pos;
	int len = s.length();
	int cnt = 0;
	double mid;
	
	for(int i=0; i<len; i++){
		cout << s[i] << endl;
		if( i>0 && i<len-1 && s[i-1]==s[i+1] ) pos.push(i);
		if( i<len-1 && s[i]==s[i+1] ) pos.push((i+i+1)*1.0/2);
		if( !pos.empty()&&i>pos.front() ){
			mid = pos.front();
			cout << "front=" << pos.front()<<endl;
			if( 2*mid-i>=0 && s[i]==s[2*mid-i] ) cnt++;
			else{
				mp[mid] = cnt;
				pos.pop();
				if( i-pos.front()==1 || i-pos.front()==0.5){
					cnt = 1;
				}else{				
					while( !pos.empty() ){
						if( i<=pos.front() ) { cnt=0;break;}
						else if( i-pos.front()==1 || i-pos.front()==0.5 ){cnt = 1;break;}
						else if( i+0.5-pos.front()>mp[2*mid-pos.front()] ){	
					
							int d;
							if( (int)(2*pos.front())%2==1 ){
								d = i+0.5-pos.front()-1;
							}else {
								d = i-pos.front()-1;
							}
						if(d==mp[2*mid-pos.front()] && s[i]==s[2*pos.front()-i] )
							{
							cnt =  mp[2*mid-pos.front()]+1;
							break;}
						else{
							mp[pos.front()] = mp[2*mid-pos.front()];
							
						}pos.pop();
						}else{
							cnt = i+0.5-pos.front();
							break;
						}
					}
					if( pos.empty() ) cnt = 0;
				}
			}
		}
	}
    if( !pos.empty() ) mp[pos.front()] = cnt;
	
	int max = 0;
	double maxid = 0;
	for(auto it=mp.begin(); it!=mp.end(); it++){	
		int t = (*it).first*2; 
		if( t%2==1 ) {
			if( (*it).second*2 >max ) {
				max = (*it).second*2;
				maxid = (*it).first;
			}
		}else {
			if( (*it).second*2+1 > max ) {
				max = (*it).second*2 + 1;
				maxid = (*it).first;
			}
		}
		cout << (*it).first << " " << (*it).second <<endl;
	}
	cout << max << endl;
	cout << s.substr((maxid+0.5)-max/2,max); 
	return 0;
}
